﻿using Abp.Domain.Entities;
using System;
using System.Collections.Generic;

namespace Laboratory.Entities.User
{
    /// <summary>
    /// 菜单
    /// </summary>
    public sealed class Menu : Entity<Guid>
    {

        #region 属性

        /// <summary>
        /// 显示名称
        /// </summary>
        public string DisplayName { get; private set; }

        /// <summary>
        ///图标
        /// </summary>
        public string Icon { get; private set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int Order { get; private set; }

        /// <summary>
        /// 链接
        /// </summary>
        public string Url { get; private set; }

        /// <summary>
        /// 深度
        /// </summary>
        public int Depth { get; private set; }

        /// <summary>
        /// 父级Id
        /// </summary>
        public Guid? ParentId { get; private set; }

        /// <summary>
        /// 是否启用
        /// </summary>
        public bool IsEnabled { get; private set; }

        /// <summary>
        /// 是否显示
        /// </summary>
        public bool IsVisible { get; private set; }

        #endregion

        /// <summary>
        /// 私有构造器 - EF用
        /// </summary>
        private Menu()
        {
        }

        /// <summary>
        /// 创建构造器
        /// </summary>
        /// <param name="displayName">显示名称</param>
        /// <param name="icon">图标</param>
        /// <param name="order">排序</param>
        /// <param name="url">链接</param>
        /// <param name="depth">深度</param>
        /// <param name="parentId">父级Id</param>
        public Menu(string displayName, string icon, int order, string url, int depth, Guid? parentId) : this()
        {
            this.Id = Guid.NewGuid();
            this.DisplayName = displayName;
            this.Icon = icon;
            this.Order = order;
            this.Url = url;
            this.Depth = depth;
            this.ParentId = parentId;
            this.IsEnabled = true;
            this.IsVisible = true;
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="displayName">显示名称</param>
        /// <param name="icon">图标</param>
        /// <param name="order">排序</param>
        /// <param name="url">链接</param>
        /// <param name="depth">深度</param>
        /// <param name="parentId">父级Id</param>
        public void Update(string displayName, string icon, int order, string url, int depth, Guid? parentId)
        {
            this.DisplayName = displayName;
            this.Icon = icon;
            this.Order = order;
            this.Url = url;
            this.Depth = depth;
            this.ParentId = parentId;
        }

        /// <summary>
        /// 设置是否启用
        /// </summary>
        /// <param name="isEnabled">是否启用</param>
        public void SetEnabled(bool isEnabled)
        {
            this.IsEnabled = isEnabled;
        }


    }
}
